package cn.stylefeng.guns.config;

import static com.google.common.base.Predicates.or;
import static springfox.documentation.builders.PathSelectors.regex;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.async.DeferredResult;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class Swagger2ListPageConfig {
    @SuppressWarnings("unchecked")
	@Bean(name="listPageConfig")
    public Docket archiveApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("列表页")
                .genericModelSubstitutes(DeferredResult.class)
                .useDefaultResponseMessages(false)
                .forCodeGeneration(false)
                .pathMapping("/")
                .select()
                .paths(or(regex("(/listPage/.*)")))//过滤的接口
                .build()
                .apiInfo(apiInfo());
    }
    @SuppressWarnings("deprecation")
	private ApiInfo apiInfo() {
    	return new ApiInfoBuilder()
                .title("市中医院门户API-列表页")
                .description("市中医院门户Api文档-列表页")
                .contact("xzqing<250863062@qq.com>")
                .version("1.0")
                .build();
    }
}
